# problem14

#testupto = 100
testupto = 1e6
maxstepnum = 0
maxsteps = 0

for n in xrange(2,1+testupto):
    currentnumber = n
    stepcount = 0
    while n != 1:
        stepcount += 1
        if n % 2 == 0:
            n = n/2
        else:
            n = 3*n + 1
            
    if stepcount > maxsteps:
        maxsteps = stepcount
        maxstepnum = currentnumber
        print "New longest: %i generates %i steps." % (maxstepnum, maxsteps)
        